//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class CEvalNumExpr {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CEvalNumExpr(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CEvalNumExpr obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CEvalNumExpr(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CEvalNumExpr.TReturnState evalExpression(String expression, SWIGTYPE_p_double result, SWIGTYPE_p_int errorIndex, long userData) {
    return CEvalNumExpr.TReturnState.swigToEnum(nelmiscJNI.CEvalNumExpr_evalExpression__SWIG_0(swigCPtr, this, expression, SWIGTYPE_p_double.getCPtr(result), SWIGTYPE_p_int.getCPtr(errorIndex), userData));
  }

  public CEvalNumExpr.TReturnState evalExpression(String expression, SWIGTYPE_p_double result, SWIGTYPE_p_int errorIndex) {
    return CEvalNumExpr.TReturnState.swigToEnum(nelmiscJNI.CEvalNumExpr_evalExpression__SWIG_1(swigCPtr, this, expression, SWIGTYPE_p_double.getCPtr(result), SWIGTYPE_p_int.getCPtr(errorIndex)));
  }

  public String getErrorString(CEvalNumExpr.TReturnState state) {
    return nelmiscJNI.CEvalNumExpr_getErrorString(swigCPtr, this, state.swigValue());
  }

  public boolean internalCheck() {
    return nelmiscJNI.CEvalNumExpr_internalCheck(swigCPtr, this);
  }

  public CEvalNumExpr() {
    this(nelmiscJNI.new_CEvalNumExpr(), true);
  }

  public final static class TReturnState {
    public final static TReturnState NoError = new TReturnState("NoError");
    public final static TReturnState UnknownValue = new TReturnState("UnknownValue");
    public final static TReturnState ValueError = new TReturnState("ValueError");
    public final static TReturnState UnknownFunction = new TReturnState("UnknownFunction");
    public final static TReturnState FunctionError = new TReturnState("FunctionError");
    public final static TReturnState NumberSyntaxError = new TReturnState("NumberSyntaxError");
    public final static TReturnState UnknownOperator = new TReturnState("UnknownOperator");
    public final static TReturnState MustBeOpen = new TReturnState("MustBeOpen");
    public final static TReturnState MustBeClose = new TReturnState("MustBeClose");
    public final static TReturnState MustBeComa = new TReturnState("MustBeComa");
    public final static TReturnState MustBeExpression = new TReturnState("MustBeExpression");
    public final static TReturnState NotUnaryOperator = new TReturnState("NotUnaryOperator");
    public final static TReturnState MustBeEnd = new TReturnState("MustBeEnd");
    public final static TReturnState MustBeDoubleQuote = new TReturnState("MustBeDoubleQuote");
    public final static TReturnState DividByZero = new TReturnState("DividByZero");
    public final static TReturnState ReturnValueCount = new TReturnState("ReturnValueCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TReturnState swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TReturnState.class + " with value " + swigValue);
    }

    private TReturnState(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TReturnState(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TReturnState(String swigName, TReturnState swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TReturnState[] swigValues = { NoError, UnknownValue, ValueError, UnknownFunction, FunctionError, NumberSyntaxError, UnknownOperator, MustBeOpen, MustBeClose, MustBeComa, MustBeExpression, NotUnaryOperator, MustBeEnd, MustBeDoubleQuote, DividByZero, ReturnValueCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
